package xu.htgl.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import xu.htgl.common.Result;
import xu.htgl.entity.Account;
import xu.htgl.service.AdminService;


@Slf4j
@RestController
public class LoginController {

    @Autowired
    private AdminService adminService;



    @PostMapping("/login")
    public Result login(@RequestBody Account account)throws Exception{
        Result dbAccount = null;
        if("ADMIN".equals(account.getRole())){
            dbAccount = adminService.login(account);
        }  else {
            return Result.failed("非法请求");
        }
        return Result.ok(dbAccount);
    }

//    @PostMapping("/register")
//    public Result register(@RequestBody User user){
//        Result login = userService.register(user);
//        return Result.ok(login);
//    }

}
